package cn.pugle.base.encrypt;

import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.BinaryCodec;
import org.apache.commons.codec.binary.Hex;

/**
 * @author tzp
 * @since 2018/3/6
 */
public class BitTest {
    public static void main(String[] args) throws DecoderException {
        byteTest();

        byte[] bytes = new byte[8];
        bytes[0] = 4;

        String s = BinaryCodec.toAsciiString(bytes);
        System.out.println(s);
        System.out.println(s.length());

        String base64 = Hex.encodeHexString(bytes);
        System.out.println(base64);
        System.out.println(base64.length());
        byte[] bytes1 = Hex.decodeHex(base64.toCharArray());
        System.out.println(bytes1[0]);
    }

    public static void byteTest() {
        Byte a = '1';
        System.out.println(a);//49

        byte b = Byte.parseByte("11", 2);
        System.out.println(b);//3

        Byte c = Byte.decode("0xa");
        System.out.println(c);//10
        System.out.println("-----------------bytes test-------------");
    }
}
